package com.example.hello_world.train_Service;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.hello_world.R;

public class service01 extends AppCompatActivity {

    private Button start_Btn,end_Btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_service01);
        start_Btn=findViewById(R.id.ser_strat01);
        end_Btn=findViewById(R.id.ser_end01);

        final Intent intent=new Intent(this,Myservice.class);
        start_Btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startService(intent);
                Toast.makeText(service01.this, "haha", Toast.LENGTH_SHORT).show();
            }
        });

        end_Btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                stopService(intent);
            }
        });
    }
}